/* 删除文件 194.c */

.LC0:
	.string "please input the name of the file which do you want to delete:\n"

.LC1:
	.string "%s"

.LC2:
	.string "r"

.LC3:
	.string "%s open successfully!"

.LC4:
	.string "%s cannot open!"

.LC5:
	.string "r"

.LC6:
	.string "\n%s has removed!"

.LC7:
	.string "error"

.globl main

main:
	pushq %rbp
	movq %rsp,%rbp
	subq $0x1000,%rsp

	movq $0,-0x1000(%rbp) /* fp */
	movl $0,-0xff8(%rbp) /* filename */

	leaq .LC0(%rip),%rdi
	movl $0,%eax 
	call printf

	leaq -0xff8(%rbp),%rsi /* filename */
	leaq .LC1(%rip),%rdi 
	movl $0,%eax 
	call scanf 

	leaq .LC5(%rip),%rsi /* r */
	leaq -0xff8(%rbp),%rdi /* filename */
	movl $0,%eax
	call fopen 
	movq %rax,-0x1000(%rbp) /* fp */
	cmpq $0,-0x1000(%rbp) /* fp */
	je .Lmain_400

	leaq -0xff8(%rbp),%rsi /* filename */
	leaq .LC3(%rip),%rdi
	movl $0,%eax 
	call printf 

	movq -0x1000(%rbp),%rdi /* fp */
	movl $0,%eax 
	call fclose 

	jmp .Lmain_300

.Lmain_400:
	leaq -0xff8(%rbp),%rsi /* filename */
	leaq .LC4(%rip),%rdi
	movl $0,%eax 
	call printf

	movl $0,%edi
	movl $0,%eax 
	call exit 

.Lmain_300:
	leaq -0xff8(%rbp),%rdi /* filename */
	movl $0,%eax
	call remove 

	leaq .LC2(%rip),%rsi
	leaq -0xff8(%rbp),%rdi 
	movl $0,%eax 
	call fopen 
	movq %rax,-0x1000(%rbp) /* fp */
	cmpq $0,-0x1000(%rbp) /* fp */
	jne .Lmain_200

	leaq -0xff8(%rbp),%rsi /* filename */
	leaq .LC6(%rip),%rdi
	movl $0,%eax
	call printf 

	jmp .Lmain_0

.Lmain_200:
	leaq .LC7(%rip),%rdi
	movl $0,%eax
	call printf 

.Lmain_0:
	movl $0,%eax
	leave
	ret
